<?php
class ServiceitemController extends  Controller{


	public function index($param){
		$this->getSmarty();
        require_once COMMON . DS  . 'Constant.class.php';

        $type = $param['type'];
		$this->smarty->assign ( 'typeleastblogs',  self::getBlogList($type));
        $this->smarty->assign ( 'pagesets', Constant::indexHeader() );
        $this->smarty->assign ( 'tplname',$type);
        
		$this->smarty->display("serviceitem.tpl");
	}
	public function getBlogList($type) {
		$table = 'posts';
		require_once SERVICE.DS."CommonLogicService.class.php";
		$common = new CommonLogicService($this->getDB());
		$page = 1;
		$rows = 3;
		$offset = ($page - 1) * $rows;
		
		$typesql = "
		SELECT 	p.*,c.category_name
			FROM 
		 posts p LEFT JOIN post_category c ON p.post_category = c.category_id WHERE c.category_name='$type' ORDER BY post_date DESC
			LIMIT 0, 3";
		$blog_lists = $common->getResults($typesql);
		foreach ($blog_lists as $k => $blog) {
			$result_bloglist[] = array (
					"post_author" => $blog->post_author,
					"post_date" => $blog->post_date,
					"post_content" => $p_content,
					"post_file_location" => $blog->post_file_location,
					"category_name" => $blog->category_name,
					"category_url" => WEBSITE_URL."blog".DS."index?type=".$blog->category_name,
					"post_title" => $blog->post_title,
					"post_url" => WEBSITE_URL."post".DS."index?id=".$blog->ID
	
			);
		}
		return $result_bloglist ;
	}
	
}